#ifndef _LOGDATBASE_H_
#define _LOGDATBASE_H_

#include "stdafx.h"

class CLogDataBaseImpl : public ILogDataBase, public IPlugin, public IPluginRun, public CUnknownImp
{
public:
    CLogDataBaseImpl();
    virtual ~CLogDataBaseImpl();

public:
    BEGIN_STDCOM_MAP
    STDCOM_INTERFACE_ENTRY_UNKNOWN_(ILogDataBase)
    STDCOM_INTERFACE_ENTRY(IPlugin)
    STDCOM_INTERFACE_ENTRY(IPluginRun)
    STDCOM_INTERFACE_ENTRY(ILogDataBase)
    END_STDCOM_MAP

    // IPlugin
    std_method(Init)(IBase* pRot, IBase* pBase);
    std_method(Uninit)();

    // IPluginRun
    std_method(Start)(_pid_t pid, unsigned int type);
    std_method(Stop)(unsigned int exit);

    // ILogDataBase
    std_method(IsTableExist)(LPCSTR name, IBase** pTable);
    std_method(SyncTable)(LPCSTR name, IBase* pBase);
    std_method(InsertTable)(UCHAR* pBuf, ULONG uSize);

private:
    std_method(OpenErrorLogDataBase)();
    std_method(UpdateTable)(LPCSTR name, ITableStruct* pITableStruct);
    std_method(CreateTable)(LPCSTR name, ITableStruct* pITableStruct);
    std_method(Insert)(LPCSTR name, sjsonptr pRoot, ITableStruct* pITableStruct);
    std_method(Update)(LPCSTR name, sjsonptr pRoot, ITableStruct* pITableStruct);
    std_method(Refresh)(LPCSTR name, sjsonptr pRoot, ITableStruct* pITableStruct);
    std_method(GetTableFields)(Table& table, ITableStruct* pITableStruct);
    std_method(ExeCommand)(LPCSTR cmd);

private:
    _lComPtr<IRot> m_pRot;
    MapTableStruct m_pMapTableStruct;
};

#endif
